﻿using DomainExample.DomainModel.PersonModel;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace DomainExample.Repository.Tests.PersonRepositoryTests
{
    [TestClass]
    public sealed class PersonRepositoryGetByIdTests : PersonRepositoryTests
    {
        private Person _testPerson;

        [TestInitialize]
        public void SetUp()
        {
            CreateSchema();
        }

        [TestCleanup]
        public void TearDown()
        {
            DestroySchema();
        }

        [TestMethod]
        [TestCategory("Database Integration")]
        public void PersonRepositoryGetByIdExpectCorrectPerson()
        {
            const string expectedFirstName = "Bob";
            const string expectedLastName = "Tester";

            AddTestPerson("Jenny", "Wrong-Result");
            _testPerson = AddTestPerson(expectedFirstName, expectedLastName);
            AddTestPerson("John", "Wrong-Result");

            var result = Target.GetById(_testPerson.Id);

            Assert.AreEqual(expectedFirstName, result.FirstName);
            Assert.AreEqual(expectedLastName, result.LastName);
        }
    }
}
